package com.km.repository;

import com.km.entity.Tags;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * <p></p>
 * Created by zhezhiyong@163.com on 2017/10/10.
 */
public interface TagsRepository extends JpaRepository<Tags, Long>, JpaSpecificationExecutor<Tags> {

    Tags findTagsByUrl(String url);
    Tags findTagsByName(String name);
    @Query(value = "SELECT b.* FROM article_tags a LEFT JOIN tags b ON a.tags_id = b.id WHERE a.article_id = ?1 ORDER BY b.id", nativeQuery = true)
    List<Tags> findTagsByArticleId(Long id);

}
